﻿using ModuleA.ViewModels;
using ModuleA.Views;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Regions;

namespace ModuleA
{
    public class ModuleAModule : IModule
    {
        public void OnInitialized(IContainerProvider containerProvider)
        {
            IRegionManager regionManager = containerProvider.Resolve<IRegionManager>();
            IRegion region = regionManager.Regions["ContentRegion"];
            var tabA = containerProvider.Resolve<TabView>();
            SetTitle(tabA, "TabA");
            region.Add(tabA);
            var tabB = containerProvider.Resolve<TabView>();
            SetTitle(tabB, "TabB");
            region.Add(tabB);
            var tabC = containerProvider.Resolve<TabView>();
            SetTitle(tabC, "TabC");
            region.Add(tabC);
        }

        public void RegisterTypes(IContainerRegistry containerRegistry)
        {

        }
        private void SetTitle(TabView tab,string title)
        {
            (tab.DataContext as TabViewModel).Title = title;
        }
    }
}